package com.rpc.spi;

import com.rpc.annotation.RpcService;

import java.lang.reflect.Field;

/**
 * Test
 *
 * @author 春江花朝秋月夜
 * @since 2024/1/18 1:30
 */
public class Test {
   @RpcService(name = "大家好")
   private String name;

    public static void main(String[] args) {
        Test test = new Test();
        //获取注解的方法要么是从字段上获取，要么是从类上获取
        for (Field declaredField : test.getClass().getDeclaredFields()) {
            test.name= declaredField.getAnnotation(RpcService.class).name();//从字段中获取加在这个字段上的注解
            System.out.println(declaredField.getAnnotation(RpcService.class).name());
        }
        System.out.println(test.name);
    }
}
